﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using PermitsAndVisasLeadsSyncher.Model;
using PermitsAndVisasLeadsSyncher.Helpers;
using System.Linq;

namespace PermitsAndVisasLeadsSyncher.Data_Gateway
{
    internal class EducationGateway
    {
        public List<Education> FillEducationList(SqlCommand command)
        {
            List<Education> educationList = new List<Education>();
            DataTable dt = new DataTable();
            command.CommandText = QueryProvider.MakeSQLQueryToFetchEducationList();
            dt = DBHelper.GetDataTable(command.CommandText);
            if (dt.Rows.Count <= 0)
            {
                return educationList;
            }
            foreach (DataRow dataRow in (InternalDataCollectionBase)dt.Rows)
            {
                educationList.Add(new Education()
                {
                    Name = dataRow["Qual_Name"].ToString()
                });
            }
            return educationList;
        }
    }
}
